<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/home/http/DsCache/trunk/DsTemplate/test/testView.php.html</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#000000" text="#ffffff"><font face="monospace">
<font color="#ffff00">&nbsp;1 </font><font color="#ff40ff">&lt;?php</font><br>
<font color="#ffff00">&nbsp;2 </font><font color="#00ffff">/**</font><br>
<font color="#ffff00">&nbsp;3 </font><font color="#00ffff">&nbsp;* 测试DsTemplate </font><br>
<font color="#ffff00">&nbsp;4 </font><font color="#00ffff">&nbsp;*</font><br>
<font color="#ffff00">&nbsp;5 </font><font color="#00ffff">&nbsp;* @filesource testView.php</font><br>
<font color="#ffff00">&nbsp;6 </font><font color="#00ffff">&nbsp;* @package DsTemplate</font><br>
<font color="#ffff00">&nbsp;7 </font><font color="#00ffff">&nbsp;* @subpackage test</font><br>
<font color="#ffff00">&nbsp;8 </font><font color="#00ffff">&nbsp;* @version $id: 0.1, utf8, Sat Jan&nbsp;&nbsp;2 16:39:27 CST 2010</font><br>
<font color="#ffff00">&nbsp;9 </font><font color="#00ffff">&nbsp;* @author LD King &lt;kldscs[at]gmail.com&gt;</font><br>
<font color="#ffff00">10 </font><font color="#00ffff">&nbsp;* @copyright Copyleft (D.) 2007 - 2009 MiFunny China Inc.</font><br>
<font color="#ffff00">11 </font><font color="#00ffff">&nbsp;* @link <a href="http://mifunny.info/">http://mifunny.info/</a></font><br>
<font color="#ffff00">12 </font><font color="#00ffff">&nbsp;* @example </font><br>
<font color="#ffff00">13 </font><font color="#00ffff">&nbsp;*&nbsp;&nbsp; </font><br>
<font color="#ffff00">14 </font><font color="#00ffff">&nbsp;*/</font><br>
<font color="#ffff00">15 </font><font color="#ff40ff">require_once</font>&nbsp;'<font color="#ffff00">../DsTemplate.class.php</font>'<font color="#ff40ff">;</font><br>
<font color="#ffff00">16 </font><br>
<font color="#ffff00">17 </font><font color="#ffff00">$</font><font color="#00ffff">template_path</font>&nbsp;<font color="#ffff00">=</font>&nbsp;<font color="#00ffff">dirname</font><font color="#ff40ff">(</font><font color="#ffff00">__FILE__</font><font color="#ff40ff">)</font><font color="#ff40ff">;</font>&nbsp;&nbsp;<font color="#00ffff">//模板文件所在目录</font><br>
<font color="#ffff00">18 </font><font color="#ffff00">$</font><font color="#00ffff">template_file</font>&nbsp;<font color="#ffff00">=</font>&nbsp;'<font color="#ffff00">testTemplate01.php</font>'<font color="#ff40ff">;</font>&nbsp;<font color="#00ffff">//模板文件</font><br>
<font color="#ffff00">19 </font><br>
<font color="#ffff00">20 </font><font color="#ffff00">$</font><font color="#00ffff">view</font>&nbsp;<font color="#ffff00">=</font>&nbsp;<font color="#ff40ff">new</font>&nbsp;DsTemplate<font color="#ff40ff">(</font><font color="#ffff00">$</font><font color="#00ffff">template_path</font><font color="#ff40ff">)</font><font color="#ff40ff">;</font>&nbsp;<font color="#00ffff">//初始化模板对象, $template_path 可为空</font><br>
<font color="#ffff00">21 </font><br>
<font color="#ffff00">22 </font><font color="#ffff00">$</font><font color="#00ffff">view</font><font color="#00ff00">-&gt;</font>TEMPLATEPATH&nbsp;<font color="#ffff00">=</font>&nbsp;<font color="#ffff00">$</font><font color="#00ffff">template_path</font><font color="#ff40ff">;</font>&nbsp;<font color="#00ffff">//重新定义模板目录, 可选</font><br>
<font color="#ffff00">23 </font><br>
<font color="#ffff00">24 </font><font color="#ffff00">$</font><font color="#00ffff">view</font><font color="#00ff00">-&gt;</font>abc&nbsp;<font color="#ffff00">=</font>&nbsp;'<font color="#ffff00">ABC</font>'<font color="#ff40ff">;</font><br>
<font color="#ffff00">25 </font><font color="#ffff00">$</font><font color="#00ffff">view</font><font color="#00ff00">-&gt;</font>king&nbsp;<font color="#ffff00">=</font>&nbsp;'<font color="#ffff00">King</font><font color="#ff40ff">\'</font><font color="#ffff00">s Zero Fourr</font>'<font color="#ff40ff">;</font>&nbsp;<font color="#00ffff">//设置变量 $abc, $king</font><br>
<font color="#ffff00">26 </font><br>
<font color="#ffff00">27 </font><font color="#ffff00">$</font><font color="#00ffff">view</font><font color="#00ff00">-&gt;</font>display<font color="#ff40ff">(</font><font color="#ffff00">$</font><font color="#00ffff">template_file</font><font color="#ff40ff">)</font><font color="#ff40ff">;</font>&nbsp;<font color="#00ffff">//显示最终结果, </font><br>
<font color="#ffff00">28 </font><font color="#00ffff">//等同 echo $view-&gt;fetch($template_file);</font><br>
<font color="#ffff00">29 </font><font color="#ff40ff">?&gt;</font><br>
</font></body>
</html>
